﻿<UserControl x:Class="Export.Ui.Pages.Order.OrderAll"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="http://www.galasoft.ch/mvvmlight"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Style="{StaticResource ContentRoot}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Grid.Column="0" Content="Upload Order" HorizontalAlignment="Right" Width="auto"  Command="{Binding UploadOrderCommand}" >

        </Button>
        <ScrollViewer Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,0,0,32">
            <StackPanel MinWidth="200">
                <!--<DataGrid x:Name="orderGrid"
                            ItemsSource="{Binding Orders}"
                            SelectedItem="{Binding SelectedItem}"
                            IsReadOnly="True">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseDoubleClick">
                            <cmd:EventToCommand Command="{Binding MouseDoubleClickCommand}"  
                                CommandParameter="{Binding ElementName=orderGrid, Path=SelectedItem}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </DataGrid>-->

                <DataGrid Name="orderGrid" ItemsSource="{Binding Orders}" SelectedItem="{Binding SelectedItem}" AutoGenerateColumns="False" IsReadOnly="True">
                    <DataGrid.Columns>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding OrderNo}" ClipboardContentBinding="{Binding OrderNo}" Header="OrderNo"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding RefOrderNo}" ClipboardContentBinding="{Binding RefOrderNo}" Header="RefOrderNo"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding OrderDate}" ClipboardContentBinding="{Binding OrderDate}" Header="OrderDate"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding InvoiceNo}" ClipboardContentBinding="{Binding InvoiceNo}" Header="InvoiceNo"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding PortOfShipment}" ClipboardContentBinding="{Binding PortOfShipment}" Header="PortOfShipment"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding PortOfDestination}" ClipboardContentBinding="{Binding PortOfDestination}" Header="PortOfDestination"/>
                        <DataGridTextColumn IsReadOnly="True" Binding="{Binding StatusName}" ClipboardContentBinding="{Binding StatusName}" Header="Status"/>
                    </DataGrid.Columns>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseDoubleClick">
                            <cmd:EventToCommand Command="{Binding MouseDoubleClickCommand}"  
                                CommandParameter="{Binding ElementName=orderGrid, Path=SelectedItem}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </DataGrid>

            </StackPanel>
        </ScrollViewer>
        <Button Content="Test Export" Command="{Binding ExportExcelCommand}" CommandParameter="{Binding ElementName=orderGrid, Path=SelectedItem}" Margin="67,10,10,0" Grid.Column="2" Grid.Row="2" VerticalAlignment="Top"/>
    </Grid>
</UserControl>
